from pyecharts import Line, Grid, Bar, Page, Pie, HeatMap, Overlap, Graph
from pyecharts_javascripthon.api import TRANSLATOR


def get_opt_from_echarts(chart):
    '''
    获取 chart 的 options
    '''
    js_snippet = TRANSLATOR.translate(chart.options)
    opt = js_snippet.option_snippet
    return opt

def test_chart_data():
    '''
    测试用图
    '''
    attr = ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"]
    v1 = [5, 20, 36, 10, 75, 90]
    v2 = [10, 25, 8, 60, 20, 80]
    bar = Bar("柱状图数据堆叠示例")
    bar.add("商家A", attr, v1, is_stack=True)
    bar.add("商家B", attr, v2, is_stack=True)
    
    opt = get_opt_from_echarts(bar)

    return opt